export default {
  name: 'foo',
  data() {
    return {
      msg: 'This is foo page.'
    }
  },
  methods: {
    // 获取列表
    getList() {
      // 参数处理
      let params = {};
      // 请求
      this.$axios.get('/api/getList', {
        params
      }).then(res => {
        if (res.status) {
          // ...
        } else {
          this.$message({
            message: res.message,
            type: 'error',
            showClose: true
          });
        }
      });
    },
    // 提交
    submit() {
      this.$refs.detourDForm.validate(valid => {
        if (valid) {
          // 参数处理
          let _this = this;
          let {
            fid,
            old_forg,
            old_fdst,
            people,
            baggage
          } = this.dialogs.detour.form;
          let params = {
            action: 'edit_flight',
            fid,
            old_forg,
            old_fdst,
            people,
            baggage
          };
          // 请求
          this.$axios.post('/flight_diversion/handle', params).then(res => {
            if (res.status) {
              this.$message({
                type: 'success',
                duration: 1000,
                showClose: false,
                message: '改航成功',
                onClose() {
                  _this.dialogs.detour.visible = false;
                }
              });
            } else {
              this.$message({
                message: res.message,
                type: 'error',
                showClose: true
              });
            }
          }).catch(() => {
            this.$message({
              message: '网络不太稳定，请再次尝试请求',
              type: 'error'
            });
          });
        }
      });
    },
    // 删除
    handleDel(sms_uid) {
      this.$confirm(`确定要删除吗？`, '删除', {
        type: 'warning',
        dangerouslyUseHTMLString: true
      }).then(() => {
        // 参数处理
        let _this = this;
        let params = {
          action: 'delete',
          sms_uid
        };
        // 请求
        this.$axios.post('sms/sms_config/handle_sms_user', params).then(res => {
          if (res.status) {
            this.$message({
              type: 'success',
              duration: 1000,
              showClose: false,
              message: '删除成功',
              onClose() {
                _this.getList();
              }
            });
          } else {
            this.$message({
              message: res.msg,
              type: 'error',
              showClose: true
            });
          }
        }).catch(() => {
          this.$message({
            message: '网络不太稳定，请再次尝试请求',
            type: 'error'
          });
        });
      });
    },
  }
}
